<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\goods\model;

use think\Model;

/**
 * 属性
 */
class Attr extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__GOODS_ATTR__';

    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    public static function getAll($map = [],$order = ''){
    	$data_list = self::view('goods_attr', true)
            ->view('goods_attrgroup', 'attrgroupname', 'goods_attrgroup.attrgroupid = goods_attr.attrgroupid', 'left')
            ->where($map)
            ->order($order)
            ->paginate();
        foreach ($data_list as $key => $value) {
        	switch ($value['inittype']) {
        		case '1':
        			$inittype = '文本';
        			break;
        		case '2':
        			$inittype = '图片';
        			break;
        		case '3':
        			$inittype = '下拉';
        			break;
        		case '4':
        			$inittype = '单选';
        			break;
        		case '5':
        			$inittype = '多选';
        			break;
        		
        	}

        	$data_list[$key]['inittype']      = $inittype;
        	$inittype = '';
        }
        return $data_list;
    }

    
}